package com.bojx.report.controller;

import com.bojx.report.validation.LoginValidation;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.kit.HashKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class LoginController extends Controller {
	private static final String SALT="qpdSpOicOf2X";
	public void index(){
		render("index.html");
	}
	
	@Before(LoginValidation.class)
	public void post(){
		String username=getPara("username");
		String password=getPara("password");
		String encryptPwd=HashKit.md5(password+SALT);
		Record userRecord=Db.findFirst("select * from report_user where username=? and password =?",username,encryptPwd);
		if(userRecord==null){
			setAttr("errorMsg", "用户名或密码不正确");
			render("index.html");
		}
	
	}
}
